package com.eastfair.venueservice.enums;

import com.eastfair.annotation.base.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * 服务订单操作记录操作类型枚举.
 *
 * @author dqq
 * @date 2022 /12/16
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ServiceOrderOperateLogOperateTypeEnum implements BaseEnum {

    /**
     * 修改订单金额.
     */
    UPDATE_ORDER_AMOUNT("修改订单金额"),

    /**
     * 编辑订单服务.
     */
    UPDATE_ORDER_SERVICE("编辑订单服务"),

    /**
     * 添加订单服务.
     */
    ADD_ORDER_SERVICE("添加订单服务"),

    /**
     * 修改服务折扣.
     */
    UPDATE_ORDER_DISCOUNT("修改服务折扣"),

    /**
     * 申请订单开票.
     */
    APPLY_ORDER_INVOICE("申请订单开票"),

    /**
     * 取消订单.
     */
    CANCEL_ORDER("取消订单"),
    ;

    private String desc;


    /**
     * 根据当前枚举的name匹配
     *
     * @param val the val
     * @param def the def
     * @return the service order operate log operate type enum
     */
    public static ServiceOrderOperateLogOperateTypeEnum match(String val, ServiceOrderOperateLogOperateTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    /**
     * Get service order operate log operate type enum.
     *
     * @param val the val
     * @return the service order operate log operate type enum
     */
    public static ServiceOrderOperateLogOperateTypeEnum get(String val) {
        return match(val, null);
    }

    /**
     * Eq boolean.
     *
     * @param val the val
     * @return the boolean
     */
    public boolean eq(ServiceOrderOperateLogOperateTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    public String getCode() {
        return this.name();
    }
}